function dlTabsPrefsFields()
{
	// The tree
	this.fieldRoot = document.getElementById("dlTabs_fieldRoot");
	// The treechildren
	this.fieldTree = document.getElementById("dlTabs_fieldTree");
	
	// Locales
	this.strbundle = document.getElementById("strings");
	
	// Save the preferences
	this.savePrefs = function()
	{
		for(var i = 0; i < this.fieldTree.childNodes.length; i++)
		{
			var row = this.fieldTree.childNodes[i].firstChild;
			if(row)
			{
				var labelcell = row.childNodes[0];
				
				dlTabsPrefs.setField(i, this.strbundle.getString("pref_" + labelcell.getAttribute("label")));
			}
		}
	}
	
	// Setup the list of fields
	this.setupFieldList = function()
	{
		for(var i = 0; i < 3; i++)
		{
			var label = dlTabsPrefs.getField(i);
			this.addToTree(label);
		}
	}
	
	// Add a row to the tree
	this.addToTree = function(field)
	{
		var treeitem = document.createElement("treeitem");
		var treerow = document.createElement("treerow");
		var labelcell = document.createElement("treecell");
		
		labelcell.setAttribute("label", this.strbundle.getString("pref_" + field));
		
		treerow.appendChild(labelcell);
		treeitem.appendChild(treerow);
		this.fieldTree.appendChild(treeitem);
	}
	
	// Get the currently selected item in the tree
	this.getSelectedItem = function()
	{
		var index = this.fieldRoot.view.selection.currentIndex
		return(this.fieldTree.childNodes[index]);
	}
	
	// Move the currently selected item up
	this.moveUp = function()
	{
		var item = this.getSelectedItem();
		if(item && item.previousSibling)
		{
			this.fieldTree.insertBefore(item, item.previousSibling);
			
			if(dlTabsPrefsDialog.prefs.instantApply)
				this.savePrefs();
		}
	}

	// Move the currently selected item down
	this.moveDown = function()
	{
		var item = this.getSelectedItem();
		if(item && item.nextSibling)
		{
			this.fieldTree.insertBefore(item.nextSibling, item);
			
			if(dlTabsPrefsDialog.prefs.instantApply)
				this.savePrefs();
		}
	}
	
	this.setupFieldList();
	
	// Add a listener to the OK button or page navigating away to save prefs
	var ok = document.documentElement.getButton("accept");
	if(ok)
	{
		ok.addEventListener("click",
			function(e)
			{
				dlTabsPrefsDialog.field.savePrefs();
			},
			false);
	}
	else
	{
		window.addEventListener("unload", 
			function(e)
			{
				dlTabsPrefsDialog.field.savePrefs();
			},
			false);
	}
}